#include <iostream>
#include <fstream>
#include <thread>

int main() {
    std::cout << "TSan demo start\n";
    static int shared = 0;

    auto worker = []() {
        for (int i = 0; i < 100000; ++i) {
            ++shared; // 数据竞争，TSan 会报警
        }
    };

    std::thread t1(worker);
    std::thread t2(worker);
    t1.join();
    t2.join();

    std::cout << "Final shared value: " << shared << '\n';
    return 0;
}
